{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                             1*1=1 \n",
      "                          2*1=2 2*2=4 \n",
      "                       3*1=3 3*2=6 3*3=9 \n",
      "                    4*1=4 4*2=8 4*3=12 4*4=16 \n",
      "                 5*1=5 5*2=10 5*3=15 5*4=20 5*5=25 \n",
      "              6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36 \n",
      "           7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49 \n",
      "        8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64 \n",
      "     9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81 \n"
     ]
    }
   ],
   "source": [
    "#以金字塔方式打印九九乘法表\n",
    "for i in range(1,10):\n",
    "    for j in range(1,i+1):\n",
    "        if j == 1:\n",
    "            print((31-3*i)*' ',f'{i}*{j}={i*j}',end = ' ')\n",
    "        else:\n",
    "            print(f'{i}*{j}={i*j}',end = ' ')\n",
    "    print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                                  2021\n",
      "\n",
      "      January                   February                   March\n",
      "Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su\n",
      "             1  2  3       1  2  3  4  5  6  7       1  2  3  4  5  6  7\n",
      " 4  5  6  7  8  9 10       8  9 10 11 12 13 14       8  9 10 11 12 13 14\n",
      "11 12 13 14 15 16 17      15 16 17 18 19 20 21      15 16 17 18 19 20 21\n",
      "18 19 20 21 22 23 24      22 23 24 25 26 27 28      22 23 24 25 26 27 28\n",
      "25 26 27 28 29 30 31                                29 30 31\n",
      "\n",
      "       April                      May                       June\n",
      "Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su\n",
      "          1  2  3  4                      1  2          1  2  3  4  5  6\n",
      " 5  6  7  8  9 10 11       3  4  5  6  7  8  9       7  8  9 10 11 12 13\n",
      "12 13 14 15 16 17 18      10 11 12 13 14 15 16      14 15 16 17 18 19 20\n",
      "19 20 21 22 23 24 25      17 18 19 20 21 22 23      21 22 23 24 25 26 27\n",
      "26 27 28 29 30            24 25 26 27 28 29 30      28 29 30\n",
      "                          31\n",
      "\n",
      "        July                     August                  September\n",
      "Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su\n",
      "          1  2  3  4                         1             1  2  3  4  5\n",
      " 5  6  7  8  9 10 11       2  3  4  5  6  7  8       6  7  8  9 10 11 12\n",
      "12 13 14 15 16 17 18       9 10 11 12 13 14 15      13 14 15 16 17 18 19\n",
      "19 20 21 22 23 24 25      16 17 18 19 20 21 22      20 21 22 23 24 25 26\n",
      "26 27 28 29 30 31         23 24 25 26 27 28 29      27 28 29 30\n",
      "                          30 31\n",
      "\n",
      "      October                   November                  December\n",
      "Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su\n",
      "             1  2  3       1  2  3  4  5  6  7             1  2  3  4  5\n",
      " 4  5  6  7  8  9 10       8  9 10 11 12 13 14       6  7  8  9 10 11 12\n",
      "11 12 13 14 15 16 17      15 16 17 18 19 20 21      13 14 15 16 17 18 19\n",
      "18 19 20 21 22 23 24      22 23 24 25 26 27 28      20 21 22 23 24 25 26\n",
      "25 26 27 28 29 30 31      29 30                     27 28 29 30 31\n",
      "\n"
     ]
    }
   ],
   "source": [
    "#生成并打印2021年的日历，要求以类似如下格式打印：\n",
    "#此为格式\n",
    "import calendar\n",
    "print(calendar.calendar(2021))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                                  2021\n",
      "       January                 February                March\n",
      "Mo Tu We Th Fr Sa Su    Mo Tu We Th Fr Sa Su    Mo Tu We Th Fr Sa Su\n",
      "       April                   May                     June\n",
      "Mo Tu We Th Fr Sa Su    Mo Tu We Th Fr Sa Su    Mo Tu We Th Fr Sa Su\n",
      "       July                    August                  September\n",
      "Mo Tu We Th Fr Sa Su    Mo Tu We Th Fr Sa Su    Mo Tu We Th Fr Sa Su\n",
      "       October                 November                December\n",
      "Mo Tu We Th Fr Sa Su    Mo Tu We Th Fr Sa Su    Mo Tu We Th Fr Sa Su\n"
     ]
    }
   ],
   "source": [
    "#生成并打印2021年的日历，要求以类似如下格式打印：\n",
    "print(34*' '+'2021')\n",
    "list1 = ['January ','February ','March','April','May','June','July','August','September','October','November','December']\n",
    "for i in range(0,12,3):\n",
    "    print(7*' '+list1[i]+(24-len(list1[i]))*' '+list1[i+1]+(24-len(list1[i+1]))*' '+list1[i+2])\n",
    "    print('Mo '+'Tu '+'We '+'Th '+'Fr '+'Sa '+'Su'+4*' '+'Mo '+'Tu '+'We '+'Th '+'Fr '+'Sa '+'Su'+4*' '+'Mo '+'Tu '+'We '+'Th '+'Fr '+'Sa '+'Su')\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Please wait a moment while I gather a list of all available modules...\n",
      "\n",
      "IPython             backcall            math                symbol\n",
      "__future__          base64              matplotlib_inline   symtable\n",
      "_abc                bdb                 mimetypes           sys\n",
      "_ast                binascii            mmap                sysconfig\n",
      "_asyncio            binhex              mmapfile            tabnanny\n",
      "_bisect             bisect              mmsystem            tarfile\n",
      "_blake2             builtins            modulefinder        telnetlib\n",
      "_bootlocale         bz2                 msilib              tempfile\n",
      "_bz2                cProfile            msvcrt              test\n",
      "_codecs             calendar            multiprocessing     textwrap\n",
      "_codecs_cn          cgi                 nest_asyncio        this\n",
      "_codecs_hk          cgitb               netbios             threading\n",
      "_codecs_iso2022     chunk               netrc               time\n",
      "_codecs_jp          cmath               nntplib             timeit\n",
      "_codecs_kr          cmd                 nt                  timer\n",
      "_codecs_tw          code                ntpath              tkinter\n",
      "_collections        codecs              ntsecuritycon       token\n",
      "_collections_abc    codeop              nturl2path          tokenize\n",
      "_compat_pickle      collections         numbers             tornado\n",
      "_compression        colorama            odbc                trace\n",
      "_contextvars        colorsys            opcode              traceback\n",
      "_csv                commctrl            operator            tracemalloc\n",
      "_ctypes             compileall          optparse            traitlets\n",
      "_ctypes_test        concurrent          os                  tty\n",
      "_datetime           configparser        parser              turtle\n",
      "_decimal            contextlib          parso               turtledemo\n",
      "_distutils_hack     contextvars         pathlib             types\n",
      "_dummy_thread       copy                pdb                 typing\n",
      "_elementtree        copyreg             perfmon             unicodedata\n",
      "_functools          crypt               pickle              unittest\n",
      "_hashlib            csv                 pickleshare         urllib\n",
      "_heapq              ctypes              pickletools         uu\n",
      "_imp                curses              pip                 uuid\n",
      "_io                 dataclasses         pipes               venv\n",
      "_json               datetime            pkg_resources       warnings\n",
      "_locale             dateutil            pkgutil             wave\n",
      "_lsprof             dbi                 platform            wcwidth\n",
      "_lzma               dbm                 plistlib            weakref\n",
      "_markupbase         dde                 poplib              webbrowser\n",
      "_md5                debugpy             posixpath           win2kras\n",
      "_msi                decimal             pprint              win32api\n",
      "_multibytecodec     decorator           profile             win32clipboard\n",
      "_multiprocessing    difflib             prompt_toolkit      win32com\n",
      "_opcode             dis                 pstats              win32con\n",
      "_operator           distutils           psutil              win32console\n",
      "_osx_support        doctest             pty                 win32cred\n",
      "_overlapped         dummy_threading     pure_eval           win32crypt\n",
      "_pickle             email               py_compile          win32cryptcon\n",
      "_py_abc             encodings           pyclbr              win32event\n",
      "_pydecimal          ensurepip           pydoc               win32evtlog\n",
      "_pyio               entrypoints         pydoc_data          win32evtlogutil\n",
      "_queue              enum                pyexpat             win32file\n",
      "_random             errno               pygments            win32gui\n",
      "_sha1               executing           pythoncom           win32gui_struct\n",
      "_sha256             faulthandler        pywin               win32help\n",
      "_sha3               filecmp             pywin32_bootstrap   win32inet\n",
      "_sha512             fileinput           pywin32_testutil    win32inetcon\n",
      "_signal             fnmatch             pywintypes          win32job\n",
      "_sitebuiltins       formatter           queue               win32lz\n",
      "_socket             fractions           quopri              win32net\n",
      "_sqlite3            ftplib              random              win32netcon\n",
      "_sre                functools           rasutil             win32pdh\n",
      "_ssl                gc                  re                  win32pdhquery\n",
      "_stat               genericpath         regcheck            win32pdhutil\n",
      "_statistics         getopt              regutil             win32pipe\n",
      "_string             getpass             reprlib             win32print\n",
      "_strptime           gettext             rlcompleter         win32process\n",
      "_struct             glob                runpy               win32profile\n",
      "_symtable           gzip                sched               win32ras\n",
      "_testbuffer         hashlib             secrets             win32rcparser\n",
      "_testcapi           heapq               select              win32security\n",
      "_testconsole        hmac                selectors           win32service\n",
      "_testimportmultiple html                servicemanager      win32serviceutil\n",
      "_testinternalcapi   http                setuptools          win32timezone\n",
      "_testmultiphase     idlelib             shelve              win32trace\n",
      "_thread             imaplib             shlex               win32traceutil\n",
      "_threading_local    imghdr              shutil              win32transaction\n",
      "_tkinter            imp                 signal              win32ts\n",
      "_tracemalloc        importlib           site                win32ui\n",
      "_warnings           inspect             six                 win32uiole\n",
      "_weakref            io                  smtpd               win32verstamp\n",
      "_weakrefset         ipaddress           smtplib             win32wnet\n",
      "_win32sysloader     ipykernel           sndhdr              winerror\n",
      "_winapi             ipykernel_launcher  socket              winioctlcon\n",
      "_winxptheme         isapi               socketserver        winnt\n",
      "_xxsubinterpreters  itertools           sqlite3             winperf\n",
      "abc                 jedi                sre_compile         winreg\n",
      "adodbapi            json                sre_constants       winsound\n",
      "afxres              jupyter             sre_parse           winxpgui\n",
      "aifc                jupyter_client      ssl                 winxptheme\n",
      "antigravity         jupyter_core        sspi                wsgiref\n",
      "argparse            keyword             sspicon             xdrlib\n",
      "array               lib2to3             stack_data          xml\n",
      "ast                 linecache           stat                xmlrpc\n",
      "asttokens           locale              statistics          xxsubtype\n",
      "asynchat            logging             string              zipapp\n",
      "asyncio             lzma                stringprep          zipfile\n",
      "asyncore            mailbox             struct              zipimport\n",
      "atexit              mailcap             subprocess          zlib\n",
      "audioop             marshal             sunau               zmq\n",
      "\n",
      "Enter any module name to get more help.  Or, type \"modules spam\" to search\n",
      "for modules whose name or summary contain the string \"spam\".\n",
      "\n"
     ]
    }
   ],
   "source": [
    "#列出自己python环境中的所有已经安装的模块\n",
    "help('modules')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nt\n",
      "c:\\Users\\Administrator\\Desktop\\python\\作业\n",
      "['2.txt', '作业2（课后作业）.ipynb', '作业3.ipynb', '作业4.ipynb']\n",
      "命令行参数如下：\n",
      "C:\\Users\\Administrator\\AppData\\Roaming\\Python\\Python38\\site-packages\\ipykernel_launcher.py\n",
      "--ip=127.0.0.1\n",
      "--stdin=9003\n",
      "--control=9001\n",
      "--hb=9000\n",
      "--Session.signature_scheme=\"hmac-sha256\"\n",
      "--Session.key=b\"71bfc588-1d09-4f56-ada2-151a99bd216e\"\n",
      "--shell=9002\n",
      "--transport=\"tcp\"\n",
      "--iopub=9004\n",
      "--f=C:\\Users\\Administrator\\AppData\\Local\\Temp\\tmp-4952ctvF8kVORJ4u.json\n",
      "['c:\\\\Users\\\\Administrator\\\\Desktop\\\\python\\\\作业', 'C:\\\\Program Files\\\\Python38\\\\python38.zip', 'C:\\\\Program Files\\\\Python38\\\\DLLs', 'C:\\\\Program Files\\\\Python38\\\\lib', 'C:\\\\Program Files\\\\Python38', '', 'C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Python\\\\Python38\\\\site-packages', 'C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Python\\\\Python38\\\\site-packages\\\\win32', 'C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Python\\\\Python38\\\\site-packages\\\\win32\\\\lib', 'C:\\\\Users\\\\Administrator\\\\AppData\\\\Roaming\\\\Python\\\\Python38\\\\site-packages\\\\Pythonwin', 'C:\\\\Program Files\\\\Python38\\\\lib\\\\site-packages']\n",
      "3.141592653589793 0.9893582466233818 -0.14550003380861354 1\n",
      "2.718281828459045\n"
     ]
    }
   ],
   "source": [
    "#尝试使用各种包与模块的引用方式去引用系统中已经安装的模块，并调用其中的函数、属性(上)\n",
    "import os\n",
    "print(os.name)\n",
    "print(os.getcwd())\n",
    "name = os.listdir(os.getcwd())\n",
    "print(name)\n",
    "import sys\n",
    "dir(sys)\n",
    "print('命令行参数如下：')\n",
    "for i in sys.argv:\n",
    "    print(i)\n",
    "print(sys.path)\n",
    "sys.version\n",
    "sys.platform\n",
    "from math import pi\n",
    "from math import sin, cos\n",
    "from random import randint\n",
    "print(pi,sin(8),cos(8),randint(1,8))\n",
    "from math import *\n",
    "print(e)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'object'>\n"
     ]
    }
   ],
   "source": [
    "#尝试使用各种包与模块的引用方式去引用系统中已经安装的模块，并调用其中的函数、属性（下）\n",
    "import sys\n",
    "sys.modules.keys()\n",
    "import builtins\n",
    "name = builtins.type.__base__\n",
    "print(name)"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "1baa965d5efe3ac65b79dfc60c0d706280b1da80fedb7760faf2759126c4f253"
  },
  "kernelspec": {
   "display_name": "Python 3.8.10 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
